package com.bfs.anasit.service;

import com.bfs.anasit.model.Record;
import com.bfs.anasit.repository.RecordRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.inject.Named;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: lukman
 * Date: 8/5/11
 * Time: 3:48 AM
 * To change this template use File | Settings | File Templates.
 */
@Service("recordService")
@Named("recordService")
@SessionScoped
public class RecordServiceImpl implements RecordService {

    @SuppressWarnings("unused")
    @PersistenceContext
    private EntityManager em;

    @Autowired
    private RecordRepository recordRepository;

    @Override
    public Record findByRecordId(Long recordId) {
        return null; //recordRepository.findByRecordId(recordId);
    }

    @Override
    public List<Record> findAllRecords() {
        return recordRepository.findAll();
    }

    @Override
    public void update(Record record) {
        recordRepository.save(record);
    }

    @Override
    public void delete(Record record) {
        recordRepository.delete(record);
    }

    @Override
    public void save(Record record) {
        recordRepository.save(record);
    }
}
